// components/navbar/navbar.js
var sys_js = require("../../utils/system.js");

Component({
  properties: {
    header: {
      type: Object,
      value: {
        title: "",
        headerbg: 'linear-gradient(#ff5c00, #ff7e00);',
        hiddenBack: true,
      }
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    statusHeight: 0,
    navHeight: 0,
    sysInfo: null,
  },

  methods: {
    backClick() {
      wx.navigateBack({
        delta: 1
      })
    },

    homeClick() {
      wx.switchTab({
        url: '/pages/index/index',
      })
    }
  },

  attached() {
    var sysInfo = sys_js.systemInfo();
    if (sysInfo) {
      var isIos = sysInfo.system.indexOf('iOS') > -1;
      var statusHeight = sysInfo.statusBarHeight;
      var navHeight = isIos ? 44 : 48;
      this.setData({
        statusHeight: statusHeight,
        navHeight: navHeight,
        sysInfo: sysInfo,
      });
    } else {
      wx.getSystemInfo({
        success: res => {
          var isIos = res.system.indexOf('iOS') > -1;
          this.setData({
            sysInfo: res,
            statusHeight: res.statusBarHeight,
            navHeight: isIos ? 44 : 48
          });
        }
      })
    }
  }
})